home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cmdline.lha / cmdline / src / cmd / cmdparse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  3.6 KB  |  121 lines

  1. //------------------------------------------------------------------------
  2. // ^FILE: cmdparse.h - define the interface to cmdparse(1)
  3. //
  4. // ^DESCRIPTION:
  5. //    This file defines a class that carries out the services provided
  6. //    by cmdparse(1).
  7. //
  8. // ^HISTORY:
  9. //    05/01/92    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  10. //
  11. //    03/01/93    Brad Appleton    <brad@ssd.csd.harris.com>
  12. //    - Added ALLOW_PLUS to list of CmdLine configuration flags
  13. //-^^---------------------------------------------------------------------
  14.  
  15. #ifndef _cmdparse_h
  16. #define _cmdparse_h
  17.  
  18. #include <cmdargs.h>
  19.  
  20.  
  21.    // Exit values used
  22. enum  ExitValues {
  23.    e_SUCCESS   = 0,      // no errors
  24.    e_USAGE     = 1,      // no errors - usage printed
  25.    e_VERSION   = 1,      // no errors - version printed
  26.    e_CMDSYNTAX = 2,      // command-line syntax error
  27.    e_BADSHELL  = 3,      // invalid shell specified
  28.    e_BADDECLS  = 4,      // invalid declaration(s) given
  29. } ;
  30.  
  31.  
  32.    // CmdArgVers is a class that simply prints (on cerr) the version
  33.    // information for this command.
  34.    //
  35. class  CmdArgVers : public CmdArg {
  36. public:
  37.    CmdArgVers(char optchar, const char * keyword, const char * description);
  38.  
  39.    virtual ~CmdArgVers(void);
  40.  
  41.    virtual  int
  42.    operator()(const char * & arg, CmdLine & cmd);
  43. } ;
  44.  
  45.  
  46. class  istream ;
  47. class  ArgSyntax ;
  48. class  UnixShell ;
  49. class  CmdParseCommand : public CmdLine {
  50. public:
  51.  
  52.    CmdParseCommand(const char * name);
  53.  
  54.    virtual  ~CmdParseCommand(void);
  55.  
  56.       // Do whatever it is we need to do!
  57.    int
  58.    operator()(CmdLineArgIter & iter) ;
  59.  
  60. private:
  61.       // Dont allow copying or assignment
  62.    CmdParseCommand(const CmdParseCommand &);
  63.    CmdParseCommand & operator=(const CmdParseCommand &);
  64.  
  65.       // Set the users arguments
  66.    void
  67.    set_args(UnixShell * shell);
  68.  
  69.       // Parse the users argument declarations
  70.    int
  71.    parse_declarations(void);
  72.  
  73.    int
  74.    parse_declarations(const char * input);
  75.  
  76.    int
  77.    parse_declarations(istream & input);
  78.  
  79.       // Add a parsed declaration to the user's argument list
  80.    int
  81.    usr_append(const char * type,
  82.               const char * varname,
  83.               ArgSyntax  & arg,
  84.               const char * description);
  85.  
  86.    //------------------------------------------------ arguments to cmdparse(1)
  87.  
  88.    CmdArgBool     anywhere;         // clear OPTS_FIRST
  89.    CmdArgBool     anycase;          // set ANY_CASE_OPTS
  90.    CmdArgBool     no_abort;         // set NO_ABORT
  91.    CmdArgBool     no_guessing;      // set NO_GUESSING
  92.    CmdArgBool     prompt;           // set PROMPT_USER
  93.    CmdArgBool     plus;             // set ALLOW_PLUS
  94.    CmdArgBool     opts_only;        // set OPTS_ONLY
  95.    CmdArgBool     kwds_only;        // set KWDS_ONLY
  96.    CmdArgBool     quiet;            // set QUIET
  97.  
  98.    CmdArgVers     version;          // print version and exit
  99.    CmdArgBool     usage;            // print usage and exit
  100.  
  101.    CmdArgBool     array_variant;    // use alternate array syntax
  102.    CmdArgStr      true_str;         // TRUE for booleans
  103.    CmdArgStr      false_str;        // FALSE for booleans
  104.    CmdArgStr      suffix_str;       // suffix for missing optional-values
  105.    CmdArgStr      usr_shell;        // the shell (command interpreter)
  106.  
  107.    CmdArgStr      input_file;       // read declarations from file
  108.    CmdArgStr      input_var;        // read declarations environment variable
  109.    CmdArgStr      input_str;        // read declarations from string
  110.  
  111.    CmdArgDummy    dummy_arg;        // "--"
  112.  
  113.    CmdArgStr      usr_prog;         // program name
  114.    CmdArgStrList  usr_args;         // program arguments
  115.  
  116.    CmdLine        usr_cmd;          // the user's CmdLine object
  117. } ;
  118.  
  119. #endif  /* _cmdparse_h */
  120.  
  121.